<!DOCTYPE html>
<html class="x-admin-sm">

<head>
	<meta charset="UTF-8">
	<title>欢迎页面-X-admin2.2</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
	<link rel="stylesheet" href="../X-admin/css/font.css">
	<link rel="stylesheet" href="../X-admin/css/xadmin.css">
	<script type="text/javascript" src="../X-admin/lib/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript" src="../X-admin/js/xadmin.js"></script>
	<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
	<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
	<style type="text/css">
		body, html{width: 100%;height: 100%;margin:0;font-family:"微软雅黑";}
		#allmap{height:1000px;width:100%;}
		#r-result{width:100%; font-size:14px;}
	</style>
	<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=Fd4HNELV6xr9GWkeMzyH1CABPpN9BbFA"></script>
	<title>城市名定位</title>
</head>
<body>
	<div id="allmap"></div>
	<!--<div id="r-result">-->
		<!--<input id="longitude" type="text" style="width:100px; margin-right:10px;" />-->
		<!--<input id="latitude" type="text" style="width:100px; margin-right:10px;" />-->
		<!--<input type="button" value="查询" onclick="theLocation()" />-->
	<!--</div>-->
</body>
</html>
<script>layui.use(['form', 'layer'],
    function() {
        var user_id12=localStorage.getItem("user_id1");
        if (null == user_id12){
            alert("请重新登陆，页面失效");
            window.location.href="login.html";
        }

        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        //自定义验证规则
        form.verify({
            nikename1: function(value) {
                if (value.length < 5) {
                    return '昵称至少得5个字符啊';
                }
            },
            pass1: [/(.+){6,12}$/, '密码必须6到12位'],
            repass1: function(value) {
                if ($('#L_pass').val() != $('#L_repass').val()) {
                    return '两次密码不一致';
                }
            }
        });


        //先查一遍根据id
        var driver_id=localStorage.getItem("task_driver_id11");
        $.ajax({
            type:"POST",
            url: "/locationdriverids",
            data:JSON.stringify({
                location_driver_id:driver_id,
                location_state:1
            }),
            contentType : "application/json;charset=UTF-8",
            success: function (data) {
                console.log(data);
                if (data.status == 200) {
                    var lists = data.data;
                    var a = null;
                    var b = null;
                    for (var i = 0; i < lists.length; i++) {
                        a = lists[i].location_longitude;
                        b = lists[i].location_latitude;
							if (a == null && b == null) {
								alert("数据出错");
								window.parent.location.reload();//刷新父页面
								parent.layer.close(index);//关闭弹出层
								return;
							}else {
								theLocation(a, b);
							}
                          }
                }
                if (data.status == 500) {
                    alert("该司机还没有发布他的位置信息")
                    var index = parent.layer.getFrameIndex(window.name);//获取当前弹出层的层级
                    // window.parent.location.reload();//刷新父页面
                    parent.layer.close(index);//关闭弹出层
                    return;
                }
			  }
            });


    });
</script>
<script type="text/javascript">
	// 百度地图API功能
	var map = new BMap.Map("allmap");
	map.centerAndZoom(new BMap.Point(),11);
	map.enableScrollWheelZoom(true);
	
	// 用经纬度设置地图中心点
	function theLocation(a,b){
		if(a != "" && b != ""){
			map.clearOverlays(); 
			var new_point = new BMap.Point(a,b);
			var marker = new BMap.Marker(new_point);  // 创建标注
			map.addOverlay(marker);              // 将标注添加到地图中
			map.panTo(new_point);      
		}
	}
</script>
